﻿using Orchard.ContentManagement.Drivers;
using Wolf.LoggedInUsers.Models;
using Wolf.LoggedInUsers.Services;

namespace Wolf.LoggedInUsers.Drivers
{
    public class LoggedInUsersPartDriver : ContentPartDriver<LoggedInUsersPart>
    {
        private readonly ILoggedInUsersService _loggedInUsersService;

        protected override string Prefix { get { return "Wolf.LoggedInUsers.LoggedInUsersPart"; } }

        public LoggedInUsersPartDriver(ILoggedInUsersService loggedInUsersService)
        {
            _loggedInUsersService = loggedInUsersService;
        }

        protected override DriverResult Display(LoggedInUsersPart part, string displayType, dynamic shapeHelper)
        {
            return ContentShape("Users_LoggedInUsers",
                    () => shapeHelper.DisplayTemplate(
                            TemplateName: "Users.LoggedInUsers",
                            Model: _loggedInUsersService.GetLoggedInUsers(),
                            Prefix: Prefix));
        }
    }
}